<!DOCTYPE html>
<html>

<meta charset="utf-8">
<head>
	<title data-localize="statistics_stove.stoveanalysis">烧结炉分析</title>
	<link rel="stylesheet" type="text/css" href="css/common.css">
	<style type="text/css">
		.u-container{
			position: relative;
			width: 100%;
			height: 140px;
			margin: 0 auto;
			margin-top: 40px;
			overflow-x: hidden;
			overflow-y: auto;
		}
		.u-container .machine:hover{
			background: #29abe2;
		}
		.u-container p{
			display: none;
		}
		.machine{
			float: left;
			height: 130px;
			text-align: center;
		}
		.machine img{
			height: 100%;
		}
		.undone{
			-webkit-filter: grayscale(100%); /* Chrome, Safari, Opera */
			filter: grayscale(100%);
			background: #d0d0d0;
		}
		.u-datacon{
			position: relative;
			width: 100%;
			height: 840px;
		}
		.u-leftline{
			position: relative;
			width: 50%;
			height: 540px;
			float: left;
		}
		.u-chartcon{
			position: relative;
			float: left;
			width: 900px;
			height: 900px;
			margin-top: 40px;
			margin-left: 100px;
			text-align: center;
			overflow: hidden;
		}
		.u-chart{
			position: relative;
			float: left;
			width: 100%;
			height: 300px;
			margin: 172px 0 0 26px;
			border-left: 1px solid #aaa;
			border-bottom: 1px solid #aaa;
		}
		.u-chartleft{
			position: absolute;
			display: block;
			height: 100%;
			width: 20px;
			left: -22px;
			top: 0;
		}
		.u-changetime{
			width: 100%;
			height: 30px;
		}
		.u-changetime input.datainp{
			text-indent: 7px;
			height: 27px;
			width: 170px;
			-webkit-border-radius: 6px;
			-moz-border-radius: 6px;
			border-radius: 6px;
			border: 1px solid #d0d0d0;
			margin-left: 4px;
		}
		.u-start{
			float: left;
			margin-left: 90px;
		}
		.u-start label,.u-end label{
			display: inline-block;
			text-align: left;
			width: 100px;
		}
		.u-end{
			float: left;
			margin-left: 10px;
		}
		.u-auto{
			line-height: 27px;
		}
		.u-chartbottom{
			position: absolute;
			display: block;
			width: 40px;
			height: 20px;
			line-height: 20px;
			margin: 0;
			left: -30px;
			bottom: -22px;
		}
		.u-chartbars{
			float: left;
			position: relative;
			height: 100%;
			width: 20px;
			margin-left: 20px;
			-webkit-transform: rotateX(180deg);
		}
		.u-chartbars .u-mname{
			position: absolute;
			left: -15px;
			top: -16px;
			line-height: 16px;
			width: 50px;
			font-size: 12px;
			-webkit-transform: rotateX(-180deg);
		}
		.u-product{
			float: left;
			height: 46px;
			width: 100%;
			bottom: 0;
			left: 0;
			background: #f5d73e;
		}
		.u-break{
			float: left;
			width: 100%;
			height: 20px;
			background: #f44336;
		}
		.u-error{
			float: left;
			width: 100%;
			height: 20px;
			background: #009fff;
		}
		.u-chartbars:nth-child(1) .u-product{
			height: 70%;
		}
		.u-chartbars:nth-child(2) .u-product{
			height: 20%;
		}
		.u-chartbars:nth-child(3) .u-product{
			height: 50%;
		}
		.u-chartbars:nth-child(4) .u-product{
			height: 90%;
		}
		.u-chartbars:nth-child(5) .u-product{
			height: 40%;
		}
		.u-xm{
			width: 100%;
			margin-top: 20px;
			text-align: left;
		}
		.u-xm label{
			width: 100px;
			display: inline-block;
			margin-left: 90px;
		}
		.u-xm select{
			width: 170px;
			height: 30px;
			-webkit-border-radius: 6px;
			-moz-border-radius: 6px;
			border-radius: 6px;
			border: 1px solid #d0d0d0;
		}
		.loading{
			background-color: rgba(255,255,255,0.9);
			background-position: center center;
			width: 100%;
			height: 100%;
			background-image: url("image/loading.gif");
			position: absolute;
			left: 0;
			top: 0;
			z-index: 10000;
			background-repeat: no-repeat;
		}
		.selectTitle{
			display: block;
			margin-bottom: 10px;
			text-align: left;
			margin-left: 50px;
			background: #f4f4f4;
			padding: 10px;
			padding-left: 50px;
			border-radius: 5px;
		}
		.selectTitle select{
			border: 1px solid #d0d0d0;
			border-radius: 5px;
			height: 30px;
			margin-left: 56px;
			width: 170px;

		}
	</style>
	<link rel="stylesheet" type="text/css" href="css/machine.css">
	<link rel="stylesheet" type="text/css" href="js/jedate/jedate.css">
</head>
<body>
<div class="loading"></div>
<div class='u-head'>
	<div class="u-headcon">
		<a href="index.html"><div class="u-mainpage" data-localize="statistics_stove.backindex">回到首页</div></a>
		<h3 data-localize="statistics_stove.stoveanalysis">烧结炉分析</h3>
		<div class="changeLang">
			<p class="u-lang"><span>中文</span><span>English</span></p>
			<div isopen="true" class="changeLangBtn"></div>
		</div>
	</div>
</div>

<div class="u-datacon">
	<div class="u-chartcon">
		<div class="selectTitle">
		<label data-localize="statistics_stove.item">项目</label>
		<select class="selectType" onchange="sel_type()">
			<option value ="2" data-localize="statistics_stove.hour">按小时</option>
			<option value ="3" data-localize="statistics_stove.minute">按分</option>
			<option value ="1" data-localize="statistics_stove.piece">按片</option>
		</select>
		</div>
		<div class="u-changetime part-changetime" hidden>
			<div class="u-start"><label data-localize="statistics_stove.begintime">开始时间</label><input type="text" class="datainp startDate1"  readonly/></div>
			<div class="u-end"><label data-localize="statistics_stove.endtime">结束时间</label><input type="text" class="datainp endDate1" readonly/></div>
		</div>
		<div class="u-changetime part-changetime" hidden style="margin-top: 20px;">
			<div class="u-start"><label data-localize="statistics_stove.begintime">开始时间</label><input type="text" class="datainp startDate2" readonly/></div>
			<div class="u-end"><label data-localize="statistics_stove.endtime">结束时间</label><input type="text" class="datainp endDate2" disabled/></div>
		</div>

		<div class="u-changetime hour-changetime" >
			<div class="u-start"><label data-localize="statistics_stove.begintime">开始时间</label><input type="text" class="datainp startDate3" readonly/></div>
			<div class="u-end"><label data-localize="statistics_stove.endtime">结束时间</label><input type="text" class="datainp endDate3" readonly/></div>
		</div>
		<div class="u-changetime hour-changetime"  style="margin-top: 20px;">
			<div class="u-start"><label data-localize="statistics_stove.begintime">开始时间</label><input type="text" class="datainp startDate4" readonly/></div>
			<div class="u-end"><label data-localize="statistics_stove.endtime">结束时间</label><input type="text" class="datainp endDate4" disabled/></div>
		</div>

		<div class="u-changetime sec-changetime" hidden>
			<div class="u-start"><label data-localize="statistics_stove.begintime">开始时间</label><input type="text" class="datainp startDate5" readonly/></div>
			<div class="u-end"><label data-localize="statistics_stove.endtime">结束时间</label><input type="text" class="datainp endDate5" readonly/></div>
		</div>
		<div class="u-changetime sec-changetime" hidden style="margin-top: 20px;">
			<div class="u-start"><label data-localize="statistics_stove.begintime">开始时间</label><input type="text" class="datainp startDate6" readonly/></div>
			<div class="u-end"><label data-localize="statistics_stove.endtime">结束时间</label><input type="text" class="datainp endDate6" disabled/></div>
		</div>

		<div class="u-xm">
			<label style="margin-left: 90px;" data-localize="statistics_stove.line">产线</label>
			<select class="u-selectLine">
			</select>
			<label style="margin-left: 10px;" data-localize="statistics_stove.equipment">设备</label>
			<select class="u-type1">
				<option value ="1" data-localize="statistics_stove.stove">烧结炉</option>
			</select>
			<br>
			<br>
			<label data-localize="statistics_stove.item">项目</label>
			<select class="u-type2">
				<option value ="1" data-localize="statistics_stove.warpageorwarp">翘曲度</option>
				<option value ="2" data-localize="statistics_stove.outofstovetempture">烧结出炉温度</option>
				<option value ="3" data-localize="statistics_stove.uoc">开路电压</option>
				<option value ="4" data-localize="statistics_stove.isc">短路电流</option>
				<option value ="5" data-localize="statistics_stove.eta">效率</option>
			</select>
			<a class="u-downloadCSV" id="downloadCSV" style="margin-left: 10px;"><div class="u-btnblue" data-localize="statistics_stove.downloadCSV">导出CSV</div></a>
			<div class="u-btnblue u-confirmbtn" data-localize="statistics_stove.confirm">确认</div>
		</div>
		<div id='canvasDiv'></div>
	</div>
</div>

<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/jquery.localize.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/language_cookie.js" charset="utf-8"></script>
<script type="text/javascript" src="js/ichart.1.2.1.min.js"></script>
<script type="text/javascript" src="js/jedate/jquery.jedate.js"></script>
<script type="text/javascript">
	var labela = [],labelb=[];
	var csvData;
	var data = [{
		name: 'A片',
		value: [null],
		color: '#0d8ecf',
		line_width: 2,
	}, {
		name: 'B片',
		value: [null],
		color: '#ef7707',
		line_width: 2,
	}];

	var chart;
	$(function() {
		$(".loading").hide();
        csvData = {
            header: ['产线ID','设备ID','设备名','项目','项目值','时间'],
            header: [langMsg.statistics_stove.lineId,langMsg.statistics_stove.equipmentId,langMsg.statistics_stove.equipmentName,langMsg.statistics_stove.item,langMsg.statistics_stove.itemvalue,langMsg.statistics_stove.time],
            body: []
        };
		labela[0] = $('.startDate1').val();
		labela[1] = $('.endDate1').val();
		labelb[0] = $('.startDate2').val();
		labelb[1] = $('.endDate2').val();

		var lineurl = getUrl('statistics_getLine');
		$.ajax({
			type:'get',
			url: lineurl,
			async : false,
			dataType: "json",
			success:function(data){
				var inhtml = "";
				if (data.resultCode == 200 && data.resultMessage == "OK") {
					for (var i = 0,len = data.resultObject.length; i < len; i++) {
						inhtml += '<option value="'+data.resultObject[i].lineId+'">'+data.resultObject[i].lineName+'</option>';
					}
					$('.u-selectLine').append(inhtml);
				}
			},
			error:function(){
				console.log("selectEqByLineId fail");
			}
		});
		chart = new iChart.LineBasic2D({
			render: 'canvasDiv',
			animation:false,
			animation_duration:'500',
			data: data,
			align: 'center',
			width: 900,
			height: 460,
			shadow: false,
			legend:{
				enable:false,
				background_color : null,
				border : {
					enable : false
				}
			},
			background_color: '#ffffff',
			tip: {
				enable: false,
				shadow: true,
				listeners: {
					//tip:提示框对象、name:数据名称、value:数据值、text:当前文本、i:数据点的索引
					parseText: function(tip, name, value, text, i) {
						return "<span style='color:#005268;font-size:12px;'>" + labels[i] + ""+ langMsg.statistics_stove.receiveabout +"<br/>" +
								"</span><span style='color:#005268;font-size:20px;'>" + value + ""+ langMsg.statistics_stove.tenthousand +"/span>";
					}
				}
			},
			sub_option: {
				smooth: false,
				label: false,
				hollow: false,
				hollow_inside: false,
				point_size: 6
			},
			coordinate: {
				width: 640,
				height: 260,
				striped_factor: 0.18,
				gridlinesVisible:false,
				grid_color: '#4e4e4e',
				axis: {
					color: '#252525',
					width: [0, 0, 2, 2]
				},
				scale: [{
					position: 'left',
					start_scale: 0,
					end_scale: 10,
					scale_space: 10,
					scale_size: 2,
					scale_enable: false,
					label: {
						color: '#333333',
						font: '微软雅黑',
						fontsize: 11,
						fontweight: 600
					},
					scale_color: '#9f9f9f'
				}]
			}
		});
		//利用自定义组件构造左侧说明文本
		chart.plugin(new iChart.Custom({
			drawFn: function() {
				//计算位置
				var coo = chart.getCoordinate(),
						x = coo.get('originx'),
						y = coo.get('originy'),
						w = coo.width,
						h = coo.height;
				//在左上侧的位置，渲染一个单位的文字
				chart.target.textAlign('start')
						.textFont('600 11px 微软雅黑')
						.textBaseline('top')
						.fillText(labelb[0], 74, y + h + 50, false, '#333333')
						.textBaseline('top')
						.fillText(labelb[1], w+74 , y + h + 50, false, '#333333')
						.textBaseline('top')
						.fillText(labela[0], 74, y + h + 8, false, '#333333')
						.textBaseline('top')
						.fillText(labela[1], w+74 , y + h + 8, false, '#333333');
				chart.target.line(x,y+300,x+w,y+300,2,'#252525');
			}
		}));
		$('.u-downloadCSV').click(function(){
			var obj = document.getElementById('downloadCSV');
			csvDownload('烧结炉分析',obj,csvData);
            csvDownload(langMsg.statistics_stove.stoveanalysis,obj,csvData);
		});
		chart.draw();

		var timeFlag = true;

		$(".startDate1").click(function(){
			timeFlag = true;
		});

		$(".endDate1").click(function(){
			timeFlag = true;
		});

		$(".startDate3").click(function(){
			timeFlag = true;
		});

		$(".endDate3").click(function(){
			timeFlag = true;
		});

		$(".startDate5").click(function(){
			timeFlag = true;
		});

		$(".endDate5").click(function(){
			timeFlag = true;
		});

		$(".startDate1").jeDate({//按片，第一个开始时间
//		dateCell:".startDate1",
			format:"YYYY-MM-DD hh:mm:ss",
			isinitVal:false,
			isTime:true, //isClear:false,
			minDate:"2014-09-19 00:00:00",
			okfun:function(val) {
				if(!timeFlag){
					$(".endDate1").val("");
				}
				if($(".endDate1").val()) { //按小时，时间范围不能超过31天
					var endDate = $(".endDate1").val();
					var startDate = $(".startDate1").val();
					var diff = timeminus(endDate,startDate);
					if(diff > 1*60*60) {
						$(".endDate1").val("");
						alert(langMsg.statistics_stove.piecetime);
						timeFlag = false;
//						return false;
					}
				}
				if($(".startDate2").val()){
					var startDate1 = $('.startDate1').val();
					var endDate1 = $('.endDate1').val();
					var startDate2 = $('.startDate2').val();
					if (startDate1 && endDate1) {
						var diff = timeminus(endDate1,startDate1);
						var date2 = timeplus(startDate2,diff);
						$('.endDate2').val(date2);
					}else{
						return false;
					}
				}

				if(!$(".endDate1").val()) {
					$(".endDate1").val($(".startDate1").val());
				}
			}
		});

		$(".endDate1").jeDate({//按片，第一个结束时间
//		dateCell:".endDate1",
			format:"YYYY-MM-DD hh:mm:ss",
			isinitVal:false,
			isTime:true, //isClear:false,
			minDate:"2014-09-19 00:00:00",
			okfun:function(val) {
				if(!timeFlag){
					$(".endDate1").val("");
				}
				if($(".startDate1").val()) { //按小时，时间范围不能超过31天
					var endDate = $(".endDate1").val();
					var startDate = $(".startDate1").val();
					var diff = timeminus(endDate,startDate);
					if(diff > 1*60*60) {
						$(".endDate1").val("");
						alert(langMsg.statistics_stove.piecetime);
						timeFlag = false;
//						return false;
					}
				}
				if($(".startDate2").val()){
					var startDate1 = $('.startDate1').val();
					var endDate1 = $('.endDate1').val();
					var startDate2 = $('.startDate2').val();
					if (startDate1 && endDate1) {
						var diff = timeminus(endDate1,startDate1);
						var date2 = timeplus(startDate2,diff);
						$('.endDate2').val(date2);
					}else{
						return false;
					}
				}
			}
		});

		$(".startDate2").jeDate({//按片，第二个开始时间
//		dateCell:".startDate2",
			format:"YYYY-MM-DD hh:mm:ss",
			isinitVal:false,
			isTime:true, //isClear:false,
			minDate:"2014-09-19 00:00:00",
			okfun:function(val) {
				var startDate1 = $('.startDate1').val();
				var endDate1 = $('.endDate1').val();
				var startDate2 = $('.startDate2').val();
				if (startDate1 && endDate1) {
					var diff = timeminus(endDate1,startDate1);
					var date2 = timeplus(startDate2,diff);
					console.log(diff,date2);
					$('.endDate2').val(date2);
				}else{
					return false;
				}
			}
		});

		$(".startDate3").jeDate({//按小时，第一个开始时间
//		dateCell:".startDate1",
			format:"YYYY-MM-DD",
			isinitVal:false,
			isTime:true, //isClear:false,
			minDate:"2014-09-19",
			okfun:function(val) {
				if(!timeFlag){
					$(".endDate3").val("");
				}
				if($(".endDate3").val() && timeFlag) { //按小时，时间范围不能超过31天
					var endDate = $(".endDate3").val();
					var startDate = $(".startDate3").val();
					var diff = timeminus(endDate,startDate);
					if(diff > 31*24*60*60) {
						$(".endDate3").val("");
						alert(langMsg.statistics_stove.hourtime);
						timeFlag = false;
//						return false;
					}
				}
				if($(".startDate4").val()){
					var startDate3 = $('.startDate3').val();
					var endDate3 = $('.endDate3').val();
					var startDate4 = $('.startDate4').val();
					if (startDate3 && endDate3) {
						var diff = timeminus(endDate3,startDate3);
						var date4 = dateFormat(timeplus(startDate4,diff),"yyyy-MM-dd");
						$('.endDate4').val(date4);
					}else{
						return false;
					}
				}

				if(!$(".endDate3").val()) {
					$(".endDate3").val($(".startDate3").val());
				}
			}
		});

		$(".endDate3").jeDate({//按小时，第一个结束时间
			format:"YYYY-MM-DD",
			isinitVal:false,
			isTime:true, //isClear:false,
			minDate:"2014-09-19",
			okfun:function(val) {
				if(!timeFlag){
					$(".endDate3").val("");
				}
				if($(".startDate3").val() && timeFlag) { //按小时，时间范围不能超过31天
					var endDate = $(".endDate3").val();
					var startDate = $(".startDate3").val();
					var diff = timeminus(endDate,startDate);
					if(diff > 2678400) {
						$(".endDate3").val("");
						alert(langMsg.statistics_stove.hourtime);
						timeFlag = false;
					}
				}
				if($(".startDate4").val()){
					var startDate3 = $('.startDate3').val();
					var endDate3 = $('.endDate3').val();
					var startDate4 = $('.startDate4').val();
					if (startDate3 && endDate3) {
						var diff = timeminus(endDate3,startDate3);
						var date4 = dateFormat(timeplus(startDate4,diff),"yyyy-MM-dd");
						$('.endDate4').val(date4);
					}else{
						return false;
					}
				}
			}
		});

		$(".startDate4").jeDate({//按小时，第二个开始时间
			format:"YYYY-MM-DD",
			isinitVal:false,
			isTime:true, //isClear:false,
			minDate:"2014-09-19",
			okfun:function(val) {
				if($(".startDate4").val()){
					var startDate3 = $('.startDate3').val();
					var endDate3 = $('.endDate3').val();
					var startDate4 = $('.startDate4').val();
					if (startDate3 && endDate3) {
						var diff = timeminus(endDate3,startDate3);
						var date4 = dateFormat(timeplus(startDate4,diff),"yyyy-MM-dd");
						$('.endDate4').val(date4);
					}else{
						return false;
					}
				}
			}
		});

		$(".startDate5").jeDate({//按分钟，第一个开始时间
//		dateCell:".startDate1",
			format:"YYYY-MM-DD hh:mm:ss",
			isinitVal:false,
			isTime:true, //isClear:false,
			minDate:"2014-09-19 00:00:00",
			okfun:function(val) {
				if(!timeFlag){
					$(".endDate5").val("");
				}
				if($(".endDate5").val() && timeFlag) { //按分钟，时间范围不能超过24小时
					var endDate = $(".endDate5").val();
					var startDate = $(".startDate5").val();
					var diff = timeminus(endDate,startDate);
					if(diff > 24*60*60) {
						alert(langMsg.statistics_stove.minututetime);
						$(".endDate5").val("");
						timeFlag = false;
//						return false;
					}
				}
				if($(".startDate6").val()){
					var startDate5 = $('.startDate5').val();
					var endDate5 = $('.endDate5').val();
					var startDate6 = $('.startDate6').val();
					if (startDate5 && endDate5) {
						var diff = timeminus(endDate5,startDate5);
						var date6 = timeplus(startDate6,diff);
						$('.endDate6').val(date6);
					}else{
						return false;
					}
				}
				if(!$(".endDate5").val()) {
					$(".endDate5").val($(".startDate5").val());
				}
			}
		});

		$(".endDate5").jeDate({//按分钟，第一个结束时间
//		dateCell:".endDate1",
			format:"YYYY-MM-DD hh:mm:ss",
			isinitVal:false,
			isTime:true, //isClear:false,
			minDate:"2014-09-19 00:00:00",
			okfun:function(val) {
				if(!timeFlag){
					$(".endDate5").val("");
				}
				if($(".startDate5").val() && timeFlag) { //按小时，时间范围不能超过31天
					var endDate = $(".endDate5").val();
					var startDate = $(".startDate5").val();
					var diff = timeminus(endDate,startDate);
					if(diff > 24*60*60) {
						alert(langMsg.statistics_stove.minututetime);
						$(".endDate5").val("");
						timeFlag = false;
//						return false;
					}
				}
				if($(".startDate6").val()){
					var startDate5 = $('.startDate5').val();
					var endDate5 = $('.endDate5').val();
					var startDate6 = $('.startDate6').val();
					if (startDate5 && endDate5) {
						var diff = timeminus(endDate5,startDate5);
						var date6 = timeplus(startDate6,diff);
						$('.endDate6').val(date6);
					}else{
						return false;
					}
				}
			}
		});

		$(".startDate6").jeDate({//按秒，第二个开始时间
			format:"YYYY-MM-DD hh:mm:ss",
			isinitVal:false,
			isTime:true, //isClear:false,
			minDate:"2014-09-19 00:00:00",
			okfun:function(val) {
				if($(".startDate6").val()){
					var startDate5 = $('.startDate5').val();
					var endDate5 = $('.endDate5').val();
					var startDate6 = $('.startDate6').val();
					if (startDate5 && endDate5) {
						var diff = timeminus(endDate5,startDate5);
						var date6 = timeplus(startDate6,diff);
						$('.endDate6').val(date6);
					}else{
						return false;
					}
				}
			}
		});

		//开始画图
		$('.u-confirmbtn').click(function(){
			csvData['body'] = [];

			var url = getUrl('statistics_stove'),
					line,startDate1,endDate1,startDate2,endDate2,type,selectType;
			line = $(".u-selectLine").val();
            selectType = $(".selectType").val();
			if (!line) {
				return false;
			}
//		startDate1 = $('.startDate1').val();
//		endDate1 = $('.endDate1').val();
//		startDate2 = $('.startDate2').val();
//		endDate2 = $('.endDate2').val();

			var startDate1 = "";
			var endDate1 = "";
			var startDate2 = "";
			var endDate2 = "";

			var typeVar = $(".selectType").val();
			if(typeVar == "1") {//按片
				startDate1 = $('.startDate1').val();
				endDate1 = $('.endDate1').val();
				startDate2 = $('.startDate2').val();
				endDate2 = $('.endDate2').val();
			}
			if(typeVar == "2") {//按小时
				startDate1 = $('.startDate3').val();
				endDate1 = $('.endDate3').val();
				startDate2 = $('.startDate4').val();
				endDate2 = $('.endDate4').val();
			}
			if(typeVar == "3") {//按秒
				startDate1 = $('.startDate5').val();
				endDate1 = $('.endDate5').val();
				startDate2 = $('.startDate6').val();
				endDate2 = $('.endDate6').val();
			}

			type = $('.u-type2').val();
			console.log(line,startDate1,endDate1,startDate2,endDate2,type,selectType);
			labela[0] = startDate1;
			labela[1] = endDate1;
			labelb[0] = startDate2;
			labelb[1] = endDate2;
			var mes = getData(line,startDate1,endDate1,startDate2,endDate2,type,url,selectType);


		})
	});

	function sel_type() { //选择查询方式(按片，按小时，按秒)后出发时间
		var typeVar = $(".selectType").val();
		if(typeVar == "1") {//按片
			$(".part-changetime").show();
			$(".hour-changetime").hide();
			$(".sec-changetime").hide();
		}

		if(typeVar == "2") {//按小时
			$(".part-changetime").hide();
			$(".hour-changetime").show();
			$(".sec-changetime").hide();
		}

		if(typeVar == "3") {//按秒
			$(".part-changetime").hide();
			$(".hour-changetime").hide();
			$(".sec-changetime").show();
		}
	}

	function getData(line,startDate1,endDate1,startDate2,endDate2,type,url,selectType){
		$(".loading").show();
		var res = null;
		$.ajax({
			type:'get',
			url: url,
//        async : false,
			dataType: "json",
			data:{"line":line,"startDate1":startDate1,"endDate1":endDate1,"startDate2":startDate2,"endDate2":endDate2,"type":type,"selectType":selectType},
			success:function(mes){
				$(".loading").hide();
				if (mes.resultCode == 200 && mes.resultMessage == "OK") {
					res = mes;
					var aaa = [0],
							bbb = [0];
					console.log(mes);

					for (var i = 0,len = mes.resultObject.aList?mes.resultObject.aList.length:0; i < len; i++) {
						aaa[i] = mes.resultObject.aList[i].yValue;
						csvData['body'].push([line,"13",langMsg.statistics_stove.stove,$('.u-type2 option:selected').text(),mes.resultObject.aList[i].yValue,mes.resultObject.aList[i].xValue]);
					}
					for (var i = 0,len = mes.resultObject.bList?mes.resultObject.bList.length:0; i < len; i++) {
						bbb[i] = mes.resultObject.bList[i].yValue;
						csvData['body'].push([line,"13",langMsg.statistics_stove.stove,$('.u-type2 option:selected').text(),mes.resultObject.bList[i].yValue,mes.resultObject.bList[i].xValue]);
					}
					var difff1 = timeminus(endDate1,startDate1),
							difff1b = timeminus(endDate2,startDate2),
							difff2 = mes.resultObject.aList[0]?timeminus(mes.resultObject.aList[mes.resultObject.aList.length-1].xValue,mes.resultObject.aList[0].xValue):0,
							difff3 = mes.resultObject.aList[0]?timeminus(mes.resultObject.aList[0].xValue,startDate1):0,
							difff2b = mes.resultObject.bList[0]?timeminus(mes.resultObject.bList[mes.resultObject.bList.length-1].xValue,mes.resultObject.bList[0].xValue):0,
							difff3b = mes.resultObject.bList[0]?timeminus(mes.resultObject.bList[0].xValue,startDate2):0;
					var per1 = (parseInt(difff3)/parseInt(difff1)),
							per1b = (parseInt(difff3b)/parseInt(difff1b)),
							per3 = (parseInt(difff2)/parseInt(difff1))
					per3b = (parseInt(difff2b)/parseInt(difff1b));

					var xnum;
					if (mes.resultObject.aList.length >= mes.resultObject.bList.length) {
						xnum = mes.resultObject.aList.length/per3;
					}else{
						xnum = mes.resultObject.bList.length/per3b;
					}

					var leftnum = parseInt(Math.round(xnum)*per1);
					var rightnum = Math.round(xnum) - leftnum -mes.resultObject.aList.length;

					var leftnumb = parseInt(Math.round(xnum)*per1b);
					var rightnumb = Math.round(xnum) - leftnumb -mes.resultObject.bList.length;

					console.log(leftnum,rightnum,leftnumb,rightnumb,xnum);
					for (var i = 0; i < leftnum; i++) {
						aaa.unshift(null);
					}
					for (var i = 0; i < rightnum; i++) {
						aaa.push(null);
					}
					for (var i = 0; i < leftnumb; i++) {
						bbb.unshift(null);
					}
					for (var i = 0; i < rightnumb; i++) {
						bbb.push(null);
					}
					data = [{
						name: langMsg.statistics_stove.Aline,
						value: aaa,
						color: '#0d8ecf',
						line_width: 2
					}, {
						name: langMsg.statistics_stove.Bline,
						value: bbb,
						color: '#ef7707',
						line_width: 2
					}];
					chart.load(data);
				}
			},
			error:function(){
				$(".loading").hide();
				console.log("fail");
			}
		});
		return res;
	}
</script>

</body>
</html>